/**
 * @author 李逢喜
 * create 2021/7/14
 */
public class ArrayStack {


    private int[] nums;

    private int count;

    public ArrayStack(int size){
        nums=new int[size];
    }


    public boolean push(int n){
        if (count==nums.length)//数组已满
            return false;

        nums[count]=n;
        count++;
        return true;

    }



    public int pop(){
        if(count==0)
            return 0;
        int n=nums[count-1];
        count--;
        return n;
    }

    public static void main(String[] args) {
        ArrayStack arrayStack=new ArrayStack(10);
        arrayStack.push(6);
        arrayStack.push(7);
        arrayStack.push(2);
        arrayStack.push(5);

        System.out.println(arrayStack.pop());
        System.out.println(arrayStack.pop());
        System.out.println(arrayStack.pop());
        System.out.println(arrayStack.pop());
    }
}
